#ifndef UART_H
#define UART_H

/* Buffersizes must be 2^n */

#define TBUFSIZE0 	 32
#define RBUFSIZE0	 32

#define TMASK0		 (TBUFSIZE0-1)
#define RMASK0		 (RBUFSIZE0-1)

#define RBUFLEN0	 (r_in0 - r_out0)
#define TBUFLEN0	 (t_in0 - t_out0)


volatile unsigned char tbuf0 [TBUFSIZE0];
volatile unsigned char rbuf0 [RBUFSIZE0];
volatile unsigned char tmpBuf [RBUFSIZE0];


volatile unsigned char t_in0;
volatile unsigned char t_out0;

volatile unsigned char r_in0;
volatile unsigned char r_out0;

volatile unsigned char i;

volatile char buffer[100];
volatile int time;
volatile char first_data_flag;

unsigned char tM0_flag;

int GetPrice(char* buffer);

int UART0_putchar (char,FILE*);
int UART0_getchar (FILE*);

void UART0_first_init (void);


#define TBUFSIZE1 	 32
#define RBUFSIZE1	 32

#define TMASK1		 (TBUFSIZE1-1)
#define RMASK1		 (RBUFSIZE1-1)

#define RBUFLEN1	 (r_in1 - r_out1)
#define TBUFLEN1	 (t_in1 - t_out1)


volatile unsigned char tbuf1 [TBUFSIZE1];
volatile unsigned char rbuf1 [RBUFSIZE1];


volatile unsigned char t_in1;
volatile unsigned char t_out1;

volatile unsigned char r_in1;
volatile unsigned char r_out1;

volatile unsigned char tM1_flag;
volatile unsigned char s_flag;
volatile unsigned char e_flag;

int UART1_putchar (char c);
int UART1_getchar (void);

void UART1_first_init (void);

void tx(unsigned char data);
void tx_str(char* str);
char rx(void);
void rx_str(void);

void connect_server(void);
void connect_router(void);
void set_wifimodule(void);
void send_message(unsigned char*);


#endif
